package {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.display.Stage;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.getTimer;
	import flash.system.Capabilities;
	
	import tea.game.dataContainer;
	import tea.game.bmpCache;
	import LFhalf.*;
	import tea.lib.KeyboardInput;
	//import tea.lib.SystemTest;
	
	public class Main {
		static private var share:Main;
		static public function get instance():Main {
			if (share == null) {
				share = new Main();
			}
			return share;
		}
		//============================
		public var canvasWidth:uint = 480;
		public var canvasHeight:uint = 320;
		public var systemData:Array;
		public var mainStage:MovieClip = new MovieClip();
		public var fps:Number;
		public var stageMC:Stage;
		static public const rootPath:String = '';
		public function log(...arg):void {
			try {
				trace(arg);
				//tracer.visible = true;
				//tracer.appendText(arg.toString() + "\n");
			}catch(e:Error){}
		}
		
		public function Main() {
			
		}
		
		public function init(_stage:Stage) {
			//init system
			stageMC = _stage;
			_stage.align = "tl";
			_stage.scaleMode = "noScale";
			KeyboardInput.intance.init(stageMC);
			//getSystemInfo();
			_stage.addChildAt(mainStage, 0);
			//load data
			var loadList:Array = [];
			loadList.push("data/dataList.xml");
			loadList.push("data/bmpList.xml");
			dataContainer.getInstance().loadAll(loadList);
			dataContainer.getInstance().addEventListener("allDone", Init2);
			//Make UI
			
			//tempInit();
			fps = 30;
			//start game
		}
		
		private function Init2(e:Event):void {
			dataContainer.getInstance().removeEventListener("allDone", Init2);
			DataProcesser.instance.init(dataContainer.getInstance().getData('data/dataList.xml'));
		}
		private function StartGame() :void {
			
		}
	}

}